import re
import pandas as pd
import numpy as np
import datetime
import time
from py2neo import Graph
import pymysql
# phone_num_1 = re.findall('^1[0-9]{10}$', '12345678901')
# print(phone_num_1)
# print(len(phone_num_1))
#
data = pd.read_csv('ins_product_data (1).csv',encoding='gb18030')
# print(data.head())

data1 = set(data['公司名称'])
print(data1)
with open('product.txt','a+') as f:
    for i in data1:
        print(i)
        f.writelines('- 我想了解一下['+i+']'+'(company)'+'\n')

# with open('company.txt','a+') as f:
#     for i in data1:
#         print(i)
#         f.writelines('- synonym: '+i+'\n'+'\t'+'examples: |'+'\n')
#

# graph = Graph(host="127.0.0.1", http_port=7474, user="neo4j", password="123456")
# print('neo4j连接上了')
# sql = "MATCH (n:product) WHERE n.name =~ '.*{}.*' RETURN n.name"
# certificate = graph.run(sql.format('中银三星')).data()
# print(certificate)
#
# print([i['n.name'] for i in certificate])

# sex = '男'
# age = '25'
# sql = "insert into " \
#       "inform_from values(0,'{sex}','{age}')".format(sex=sex,age=age)
# print('mysql_sql',sql)
#
# date = datetime.datetime.now().strftime("%d/%m/%Y")
# localtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
# print(type(date))
# print(localtime,type(localtime))

#
# connetct = pymysql.Connect(host='localhost',
#                            port=3306,
#                            user='root',
#                            passwd='root',
#                            db='insurance_chatbot',
#                            charset='utf8')
# print('mysql连接上了')
# cursor = connetct.cursor()
# try:
#     sql = "SELECT phone_num from information_from"
#     result = cursor.execute(sql)
#     # 提交结果
# except Exception as e:
#     print('mysql录入信息失败', e)
#     # 事务回滚，撤销前面的操作
#     connetct.rollback()
# finally:
#     # 关闭数据库
#     cursor.close()
#     connetct.close()


# a = '北京科技馆。'
# print(a[:-1])

# a = '20万'
# if '万' in a:
#     s = re.findall('\d+',a)
#     print(type(s))
#     a = int(s[0])*10000
#     print(type(a))

# year_incoming = '25万'
# if '万' in year_incoming:
#     ret1 = re.findall('\d+', year_incoming)
#     print('ret1',type(ret1))
#     year_incoming_1 = int(ret1[0]) * 10000
# else:
#     year_incoming_1 = int(year_incoming)
#
# print(year_incoming_1)

# text1 =  [{'m.name': '长生天地逍遥行综合交通意外伤害保险'}, {'m.name': '长生附加团体重大疾病保险（J）'}]
# str = ""
# for i in text1:
#     text = i['m.name']
#     str += text+'\n'
# print(str)